﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PhotoHsn.BLL.Adapters;
using Bxas.Utility.Web.Keepers;
using PhotoHsn.BLL.Core;
using PhotoHsn.WebApp.Core;
using PhotoHsn.BLL.Authantication;

namespace PhotoHsn.Web
{
    public partial class ChangePassword : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void lnkBtnSubmit_Click(object sender, EventArgs e)
        {
            Members member = ((MemberUser)SessionKeeper.get_value(SessionNames.MemberUser)).Member;
            if (member.Password == Bxas.Utility.Security.MD5Operations.convert_string_to_MD5(txtOldPassword.Text))
            {
                MembersBs memberBs = new MembersBs();
                member.Password = Bxas.Utility.Security.MD5Operations.convert_string_to_MD5(txtNewPassword.Text);
                memberBs.update(member);
                SessionKeeper.add(SessionNames.Message, "Şifreniz değişmiştir. Yeni şifreniz ile sisteme giriş yapabilirsiniz.");
                SessionKeeper.add(SessionNames.EnumMessageTypes, EnumMessageTypes.Bilgi);
                SessionKeeper.remove(SessionNames.MemberUser);
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                MessageShow("Eski şifrenizi yanlış girdiniz", EnumMessageTypes.Uyari);
            }
        }
    }
}